<?php
    include_once("../inc/login_controll.inc.php");
	include_once("../class/config.class.php"); 
	$config = config::getConfig();
	include_once($config->getValue("home_path")."/inc/defines.inc.php");

	include_once(HOME_PATH."/class/form.class.php");
	include_once(HOME_PATH."/class/database.class.php");
	include_once(HOME_PATH."/class/user.class.php");
	
	$oForm = new form($config);
	$oDB = new database($config);
	$oForm->setDB($oDB);

	if(isset($_GET['f']) && $_GET['f']!=""){
		$iFormId = (int)$_GET['f'];
		if($oForm->userIsOwnerOfForm($_SESSION['user_id'], $iFormId)){			
			$oForm->deleteForm($iFormId);
		}
		header("location:teacher.php");
	}

	if(isset($_GET['q']) && $_GET['q']!=""){
		$iQuestionId = (int)$_GET['q'];
		$iFormId = $oForm->getFormByQuestionId($iQuestionId);
		if($oForm->userIsOwnerOfForm($_SESSION['user_id'], $iFormId)){			
			$oForm->deleteQuestion($iQuestionId);
		}
		header("location:edit.php?f=$iFormId");
	}
?>